<?php
/**
 * @property string $id
 * @property string $username
 * @property string $password
 * @property double $cash
 * @property string $active_ts
 * @property double $xp
 * @property string $avatar
 * @property string $status
 *
 * The followings are the available model relations:
 * @property GameUserHot[] $gameUserHots
 */
class User extends CActiveRecord
{
	public function tableName()
	{
		return 'user';
	}

	public function rules()
	{
		return array(
			array('username, password, cash, active_ts, xp, avatar, status', 'required'),
			array('cash, xp', 'numerical'),
			array('username, avatar', 'length', 'max'=>50),
			array('password', 'length', 'max'=>32),
			array('status', 'length', 'max'=>1),
			array('id, username, password, cash, active_ts, xp, avatar, status', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}

	public function attributeLabels()
	{
		return array(
			'id' => 'ИД',
			'username' => 'Логин',
			'password' => 'Пароль',
			'cash' => 'Деньги',
			'active_ts' => 'Активность',
			'xp' => 'Опыт',
			'avatar' => 'Ава',
			'status' => 'Статус',
		);
	}

	public function search()
	{
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('cash',$this->cash);
		$criteria->compare('active_ts',$this->active_ts,true);
		$criteria->compare('xp',$this->xp);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('status',$this->status,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
